from django.db import models


# Create your models here.
class Room(models.Model):
    STATUS = [
        (-1, "下架"),
        (0, "空闲"),
        (1, "短期租用"),
        (2, "长期租用")
    ]
    TYPE = [
        (0, "无"),
        (1, "单人间"),
        (2, "双人间"),
        (4, "四人间"),
    ]
    name = models.CharField(max_length=255, null=True)
    size = models.FloatField(null=True)
    price = models.FloatField(null=True)
    city = models.CharField(max_length=255, null=True)
    address = models.CharField(max_length=255, null=True)
    type = models.IntegerField(choices=TYPE)
    status = models.IntegerField(default=0, choices=STATUS)
    # 房主信息
    managerName = models.CharField(max_length=255, null=True)
    mobile = models.CharField(max_length=255, null=True)
    email = models.EmailField(max_length=255, null=True)
    # 租房用户
    uid = models.IntegerField(default=0)

    def get_info(self):
        dic = dict()
        dic['rid'] = self.id
        dic['type'] = self.type
        dic['status'] = self.status
        dic['name'] = self.name
        dic['price'] = self.price
        dic['city'] = self.city
        dic['address'] = self.address
        dic['size'] = self.size
        
        dic['managerName'] = self.managerName
        dic['mobile'] = self.mobile
        dic['email'] = self.email
        dic['uid'] = self.uid
        return dic
